home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gsl.idb / usr / freeware / include / gsl_complex.h.z / gsl_complex.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  1.5 KB  |  56 lines

  1. #ifndef _GSL_COMPLEX_H
  2. #define _GSL_COMPLEX_H
  3.  
  4.  
  5. /* two consecutive built-in types as a complex number */
  6. typedef double *       gsl_complex_packed ;
  7. typedef float *        gsl_complex_packed_float  ;
  8. typedef long double *  gsl_complex_packed_long_double ;
  9.  
  10. /* 2N consecutive built-in types as N complex numbers */
  11. typedef double *       gsl_complex_packed_array ;
  12. typedef float *        gsl_complex_packed_array_float  ;
  13. typedef long double *  gsl_complex_packed_array_long_double ;
  14.  
  15.  
  16. /* Yes... this seems weird. Trust us. The point is just that
  17.    sometimes you want to make it obvious that something is
  18.    an output value. The fact that it lacks a 'const' may not
  19.    be enough of a clue for people in some contexts.
  20.  */
  21. typedef double *       gsl_complex_packed_ptr ;
  22. typedef float *        gsl_complex_packed_float_ptr  ;
  23. typedef long double *  gsl_complex_packed_long_double_ptr ;
  24.  
  25.  
  26. typedef struct
  27.   {
  28.     long double dat[2];
  29.   }
  30. gsl_complex_long_double;
  31.  
  32. typedef struct
  33.   {
  34.     double dat[2];
  35.   }
  36. gsl_complex;
  37.  
  38. typedef struct
  39.   {
  40.     float dat[2];
  41.   }
  42. gsl_complex_float;
  43.  
  44. #define GSL_REAL(z)     ((z).dat[0])
  45. #define GSL_IMAG(z)     ((z).dat[1])
  46. #define GSL_COMPLEX_P_REAL(zp)  ((zp)->dat[0])
  47. #define GSL_COMPLEX_P_IMAG(zp)  ((zp)->dat[1])
  48. #define GSL_COMPLEX_EQ(z1,z2) ((z1).dat[0] == (z2).dat[0] && \
  49.                    ((z1).dat[1] == (z2).dat[1]))
  50.  
  51. #define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
  52. #define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
  53. #define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
  54.  
  55. #endif /* _GSL_COMPLEX_H */
  56.